<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nodes="http://www.nodes.de/nodes/1.0" xmlns:repo="xalan://offset.nodes.server.model.RepositoryUtils">
    <xsl:import href="template-basic.xsl"/>

    <xsl:output method="html"/>


    <xsl:template match="/" ><xsl:apply-templates select="nodes:useCase"/></xsl:template>

    <xsl:template name="nodes_useCase.NAME" match="nodes:useCase/@NAME">
        <h1 n-id="{@jcr:uuid}" n-data="nodes:useCase/@NAME">
            <!--Name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </h1>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_id" match="nodes:useCase/@nodes:id">
        <h3 n-id="{@jcr:uuid}" n-data="nodes:useCase/@nodes:id">
            <!--The short id.-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </h3>
    </xsl:template>

    <xsl:template name="secondary1.nodes_useCaseActor.NAME" match="/secondary1/nodes:useCaseActor/@NAME">
    <!--Name-->
        <a href="/nodes/registry?ref={../@jcr:uuid}" n-edit="true" n-view="offset.nodes.client.editor.view.virtual.ev.NodeFromTypeChooser" n-data="/secondary1/nodes:useCaseActor/@NAME">
    <xsl:call-template name="value-of">
        <xsl:with-param name="input" select="."/>
    </xsl:call-template>
        </a>
    </xsl:template>

    <xsl:template name="secondary1.nodes_useCaseActor" match="/secondary1/nodes:useCaseActor">
        <tr n-edit="explicit" n-schema="nodes:useCaseActor" valign="top" n-primary-reference="{@jcr:uuid}" n-data="/secondary1/nodes:useCaseActor" n-id="{@jcr:uuid}">
            <td width="100%">
                <xsl:for-each select="@NAME">
                    <xsl:call-template name="secondary1.nodes_useCaseActor.NAME"/>
                </xsl:for-each>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_description.jcr_data" match="nodes:useCase/nodes:description/@jcr:data">
        <div n-binary="true" n-data="nodes:useCase/nodes:description/@jcr:data">
            <xsl:value-of disable-output-escaping="yes" select="."/>
        </div>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_description" match="nodes:useCase/nodes:description">
        <div n-id="{@jcr:uuid}" n-data="nodes:useCase/nodes:description">
            <xsl:for-each select="@jcr:data">
                <xsl:call-template name="nodes_useCase.nodes_description.jcr_data"/>
            </xsl:for-each>
        </div>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_exceptionalCases.nodes_useCase.nodes_id" match="nodes:useCase/nodes:exceptionalCases/nodes:useCase/@nodes:id">
    <!--Id-->
        <a href="/nodes/registry?ref={../@jcr:uuid}" n-data="nodes:useCase/nodes:exceptionalCases/nodes:useCase/@nodes:id">
    <xsl:call-template name="value-of">
        <xsl:with-param name="input" select="."/>
    </xsl:call-template>
        </a>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_exceptionalCases.nodes_useCase.NAME" match="nodes:useCase/nodes:exceptionalCases/nodes:useCase/@NAME">
        <td n-id="{@jcr:uuid}" width="89%" n-data="nodes:useCase/nodes:exceptionalCases/nodes:useCase/@NAME">
            <!--The name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_exceptionalCases.nodes_useCase" match="nodes:useCase/nodes:exceptionalCases/nodes:useCase">
        <tr n-id="{@jcr:uuid}" n-data="nodes:useCase/nodes:exceptionalCases/nodes:useCase" valign="top">
            <td width="11%">
                <xsl:for-each select="@nodes:id">
                    <xsl:call-template name="nodes_useCase.nodes_exceptionalCases.nodes_useCase.nodes_id"/>
                </xsl:for-each>
            </td>
            <xsl:for-each select="@NAME">
                <xsl:call-template name="nodes_useCase.nodes_exceptionalCases.nodes_useCase.NAME"/>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_exceptionalCases" match="nodes:useCase/nodes:exceptionalCases">
        <div n-id="{@jcr:uuid}" n-data="nodes:useCase/nodes:exceptionalCases">
            <h2>
                Exceptional cases
            </h2>
            <table width="100%">
                <tr valign="top">
                    <td width="11%" class="label">
                        Id
                    </td>
                    <td width="89%" class="label">
                        Name
                    </td>
                </tr>
                <xsl:for-each select="nodes:useCase">
                    <xsl:call-template name="nodes_useCase.nodes_exceptionalCases.nodes_useCase"/>
                </xsl:for-each>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_requirement.jcr_primaryType" match="nodes:useCase/nodes:requirement/@jcr:primaryType">
        <td n-select="childType" n-id="{@jcr:uuid}" width="4%" n-data="nodes:useCase/nodes:requirement/@jcr:primaryType">
            <img title="{../@jcr:primaryType}" src="/nodes/registry?propertyName=jcr%3AprimaryType&amp;contentType=icon&amp;nodeType=nodes%3Arequirement&amp;propertyValue={../@jcr:primaryType}">
            </img>
        </td>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_requirement.nodes_id" match="nodes:useCase/nodes:requirement/@nodes:id">
    <!--Id-->
        <a href="/nodes/registry?ref={../@jcr:uuid}" n-data="nodes:useCase/nodes:requirement/@nodes:id">
    <xsl:call-template name="value-of">
        <xsl:with-param name="input" select="."/>
    </xsl:call-template>
        </a>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_requirement.NAME" match="nodes:useCase/nodes:requirement/@NAME">
        <td n-id="{@jcr:uuid}" width="84%" n-data="nodes:useCase/nodes:requirement/@NAME">
            <!--Name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_useCase.nodes_requirement" match="nodes:useCase/nodes:requirement">
        <tr n-id="{@jcr:uuid}" n-data="nodes:useCase/nodes:requirement" valign="top">
            <xsl:for-each select="@jcr:primaryType">
                <xsl:call-template name="nodes_useCase.nodes_requirement.jcr_primaryType"/>
            </xsl:for-each>
            <td width="11%">
                <xsl:for-each select="@nodes:id">
                    <xsl:call-template name="nodes_useCase.nodes_requirement.nodes_id"/>
                </xsl:for-each>
            </td>
            <xsl:for-each select="@NAME">
                <xsl:call-template name="nodes_useCase.nodes_requirement.NAME"/>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="nodes_useCase" match="nodes:useCase">
        <div n-schema="nodes:useCase" n-id="{@jcr:uuid}" n-data="nodes:useCase">
            <xsl:for-each select="@NAME">
                <xsl:call-template name="nodes_useCase.NAME"/>
            </xsl:for-each>
            <xsl:for-each select="@nodes:id">
                <xsl:call-template name="nodes_useCase.nodes_id"/>
            </xsl:for-each>
            <h2>
                Actors
            </h2>
            <table width="100%">
                <tr valign="top">
                    <td width="100%" class="label">
                        Name
                    </td>
                </tr>
                <xsl:for-each select="/secondary1/nodes:useCaseActor">
                    <xsl:call-template name="secondary1.nodes_useCaseActor"/>
                </xsl:for-each>
            </table>
            <p>
            </p>
            <xsl:for-each select="nodes:description">
                <xsl:call-template name="nodes_useCase.nodes_description"/>
            </xsl:for-each>
            <xsl:for-each select="nodes:exceptionalCases">
                <xsl:call-template name="nodes_useCase.nodes_exceptionalCases"/>
            </xsl:for-each>
            <xsl:if test="nodes:requirement">
            <div>
                <h2>
                    Variants
                </h2>
                <table width="100%">
                    <tr valign="top">
                        <td width="4%" class="label">
                            Type
                        </td>
                        <td width="11%" class="label">
                            Id
                        </td>
                        <td width="84%" class="label">
                            Name
                        </td>
                    </tr>
                    <xsl:for-each select="nodes:requirement">
                        <xsl:call-template name="nodes_useCase.nodes_requirement"/>
                    </xsl:for-each>
                </table>
            </div>
            </xsl:if>
        </div>
    </xsl:template>

</xsl:stylesheet>
